package cn.jiyun.kafka.consumer;

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class HelloListener {
    @KafkaListener(topics = "kafka-hello-2111A")
    public void reviceMsg(ConsumerRecord<String,String>record){
        Optional<ConsumerRecord<String, String>> optional = Optional.ofNullable(record);

        if (optional.isPresent()){
            String value=record.value();
            System.out.println(value);
        }
    }
}
